Fix conversion options validation failing on type and callable objects#1667
Merged
bendichter merged 6 commits intomainfrom Feb 18, 2026
Merged
Fix conversion options validation failing on type and callable objects#1667bendichter merged 6 commits intomainfrom
bendichter merged 6 commits intomainfrom
Conversation
`validate_conversion_options` was updated in #1139 to JSON-encode conversion_options before schema validation. This broke passing `progress_bar_class` (a type) and callback functions in `progress_bar_options`, as the encoder had no handler for these types. Add handling for `type` and `callable` objects in `_NWBConversionOptionsEncoder`, serializing them to their qualified module path for validation purposes. The original objects are still passed through to the actual conversion code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
@h-mayorquin can you please look at this when you get a chance? |
h-mayorquin
approved these changes
Feb 15, 2026
Collaborator
h-mayorquin
left a comment
There was a problem hiding this comment.
Needs a test and a changelog but LGTM.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bendichter
commented
Feb 18, 2026
bendichter
commented
Feb 18, 2026
h-mayorquin
approved these changes
Feb 18, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1667 +/- ##
=======================================
Coverage 80.22% 80.22%
=======================================
Files 160 160
Lines 12655 12659 +4
=======================================
+ Hits 10152 10156 +4
Misses 2503 2503
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
validate_conversion_optionswas updated in Support datetime in conversion options #1139 to JSON-encode conversion_options before schema validation. This broke passingprogress_bar_class(atypeobject) and callback functions inprogress_bar_options, as_NWBConversionOptionsEncoderhad no handler for these types.typeandcallableobjects in_NWBConversionOptionsEncoder, serializing them to their qualified module path string for validation purposes. The original objects are still passed through to the actual conversion code unchanged.How this manifests
NWB GUIDE sets
progress_bar_class=TQDMProgressSubscriber(a class, not an instance) initerator_optswithinconversion_optionsatmanage_neuroconv.py:1021:This dict ends up in
conversion_options, which is passed toNWBConverter.run_conversion(). Insiderun_conversion(nwbconverter.py:319):Which calls (
nwbconverter.py:201):The encoder has no handler for
typeorcallableobjects, so it falls through tojson.JSONEncoder.default()which raises:At runtime (after validation), the conversion_options dict is unpacked as kwargs into each interface's
add_to_nwbfile()(nwbconverter.py:253):This passes
iterator_optsas a kwarg, which flows through toSpikeInterfaceRecordingDataChunkIterator/ImagingExtractorDataChunkIterator, then to hdmf'sGenericDataChunkIterator, whereprogress_bar_classis used as a constructor. This runtime path works fine — the issue is only in the validation step.Before vs after #1139
Before #1139, validation was:
jsonschema.validate()traverses the dict but doesn't serialize it, so class objects were fine.After #1139:
The JSON encode/decode round-trip fails on non-serializable types.
Test plan
progress_bar_classas a type object inconversion_optionsno longer raisesTypeError: Object of type type is not JSON serializableprogress_bar_optionsworks🤖 Generated with Claude Code